/*
 * @Author: Lee 497232807@qq.com
 * @Date: 2023-07-21 09:13:28
 * @LastEditors: Lee 497232807@qq.com
 * @LastEditTime: 2023-07-24 14:16:26
 * @FilePath: \ccc-hot-update\assets\Game\10000\game.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { assetManager, instantiate, sys } from 'cc';
import { v3 } from 'cc';
import { view } from 'cc';
import { Button } from 'cc';
import { tween } from 'cc';
import { _decorator, Component, Prefab } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('game')
export class game extends Component {


    @property(Button)
    btn_game: Button = null;

    /**
     * 回到大厅界面
     */
    @property(Button)
    btn_home: Button = null;


    @property(Prefab)
    prefab_game: Prefab = null;

    start() {
        this.btn_game.node.on('click', this.onBtnClick, this);
        this.btn_home.node.on('click', this.onBtnHome, this);
    }

    protected onBtnClick() {    

        let node = instantiate(this.prefab_game);
        node.parent = this.node;

        var size = sys.getSafeAreaRect();
        node.setPosition(0,-size.height/2,0);
        tween(node).to(1, {position: v3(0,size.height/2,0)}).removeSelf().start();
             
    }

    protected onBtnHome()
    {
        this.node.destroy();
        //TODO 回到大厅 卸载当前bundle
        var bundle = assetManager.getBundle("10000");
        if(bundle)
        {
            bundle.releaseAll();
        }
    }

   
}


